package com.example.demo.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.List;
import java.util.Objects;

@Entity
public class Role {
    private int rid;
    private String rName;
    private String rTitle;
    private String rdescript;
    private Date rtime;
    private List<User> yh;
    private List<Fun> gn;

    @Id
    @Column(name = "rid", nullable = false)
    public int getRid() {
        return rid;
    }

    public void setRid(int rid) {
        this.rid = rid;
    }

    @Basic
    @Column(name = "rName", nullable = true, length = 20)
    public String getrName() {
        return rName;
    }

    public void setrName(String rName) {
        this.rName = rName;
    }

    @Basic
    @Column(name = "rTitle", nullable = true, length = 20)
    public String getrTitle() {
        return rTitle;
    }

    public void setrTitle(String rTitle) {
        this.rTitle = rTitle;
    }

    @Basic
    @Column(name = "rdescript", nullable = true, length = 100)
    public String getRdescript() {
        return rdescript;
    }

    public void setRdescript(String rdescript) {
        this.rdescript = rdescript;
    }

    @Basic
    @Column(name = "rtime", nullable = true)
    public Date getRtime() {
        return rtime;
    }

    public void setRtime(Date rtime) {
        this.rtime = rtime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Role role = (Role) o;
        return rid == role.rid &&
                Objects.equals(rName, role.rName) &&
                Objects.equals(rTitle, role.rTitle) &&
                Objects.equals(rdescript, role.rdescript) &&
                Objects.equals(rtime, role.rtime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rid, rName, rTitle, rdescript, rtime);
    }

    @ManyToMany(mappedBy = "js")
    public List<User> getYh() {
        return yh;
    }

    public void setYh(List<User> yh) {
        this.yh = yh;
    }

    @ManyToMany
    @JoinTable(name = "rolefun", catalog = "", schema = "byxm", joinColumns = @JoinColumn(name = "rid", referencedColumnName = "rid", nullable = false), inverseJoinColumns = @JoinColumn(name = "fid", referencedColumnName = "fid", nullable = false))
    public List<Fun> getGn() {
        return gn;
    }

    public void setGn(List<Fun> gn) {
        this.gn = gn;
    }
}
